#!/usr/bin/python

from Cache import Cache
import urllib2

class scraperBase:
	def __init__(self,debug=False):
		self.debug = debug
		self.cache = Cache(self.name,debug=debug)

	def HTTP_Get(self,type,name,url):
		assert type
		assert name
		assert url
		x = self.cache.GetCache(type,name)
		if not x:
			if self.debug:
				print "Item",type,"-",name,"not in cache"
			#Item not in cache

			#TEMPORARY FOR DEBUGGING WHILE USING TEMPLATES
			if url[0:7] == "http://":
				print "Loading url"
				url = urllib2.urlopen(url).read()

			self.cache.AddCache(type,name,url)
			x = url
		return x
		
